import java.io.*;

public class FileCopy {
    public static void main(String[] args) {
        try {
            FileInputStream fileInputStream = new FileInputStream("video.mp4");
            FileOutputStream fileOutputStream = new FileOutputStream("video-copy.mp4");
            // 获取当前系统的时间，单位 毫秒
            long start = System.currentTimeMillis();
            /*// 每次读取 1 个 字节
            int b;
            while ((b = fileInputStream.read()) != -1) {
                fileOutputStream.write(b);
            }*/

            /*byte[] bytes = new byte[64];
            int length;
            while ((length = fileInputStream.read(bytes)) != -1) {
                fileOutputStream.write(bytes,0, length);
            }*/

            BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
            BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream);

            byte[] bytes = new byte[8192];
            int length;
            while ((length = bufferedInputStream.read(bytes)) != -1) {
                bufferedOutputStream.write(bytes,0, length);
            }

            // 获取当前系统时间，单位 毫秒
            long end = System.currentTimeMillis();

            fileOutputStream.close();
            fileInputStream.close();

            System.out.println(end - start);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
